# Python 2.6.4
# Project Euler, Problem 191
# Copyright 2010 Talha Zaman

memo = {}
def prize(d, ab):
    if memo.has_key((d, ab)): return memo[(d,ab)]
    if ab==3: return 0
    if d==0: return 1
    memo[(d,ab)] = prize(d-1, 0) + prize(d-1, ab+1)
    return memo[(d,ab)]

def count(days):
    return prize(days,0) + sum(prize(days-1-x,0)*prize(x,0) for x in range(days))

print count(30)
